package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.HfFastBank;
import com.sc.nft.mapper.HfFastBankMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 汇付支付卡表(sc_hf_fast_bank)数据DAO
 *
 * @author 张翔宇
 * @since 2023-03-07 13:30:18
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class HfFastBankDao extends ServiceImpl<HfFastBankMapper, HfFastBank> {

    public List<HfFastBank> getListByUserId(Long userId){
        LambdaQueryWrapper<HfFastBank> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HfFastBank::getUserId,userId);
        wrapper.eq(HfFastBank::getStatus,true);
        return list(wrapper);
    }



    public HfFastBank getByUserCard(Long userId,String cardNo){
        LambdaQueryWrapper<HfFastBank> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HfFastBank::getUserId,userId);
        wrapper.eq(HfFastBank::getBankCardNo,cardNo);
        wrapper.eq(HfFastBank::getStatus,true);
        wrapper.last("limit 1");
        return getOne(wrapper);
    }

    public Integer getCountByUserId(Long userId){
        LambdaQueryWrapper<HfFastBank> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HfFastBank::getUserId,userId);
        wrapper.eq(HfFastBank::getStatus,true);

        return count(wrapper);
    }

}